package com.zwj.dto;

import com.zwj.enums.RoleTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户类型
 * @author zwj
 */
@Getter
@AllArgsConstructor
public class UserType {
    private static final List<String> paths = new ArrayList<>();
    static {
        paths.add("class");
        paths.add("user");
        paths.add("team");
        paths.add("course");
        paths.add("Homework");
        paths.add("work-submit-info-entity");
    }
    /**
     * 管理员标识
     */
    public static final UserType USER_TYPE_ADMIN = new UserType("admin", "管理员");

    /**
     * 老师标识
     */
    public static final UserType USER_TYPE_TEACHER = new UserType("_t", "教师");

    /**
     * 学生标识
     */
    public static final UserType USER_TYPE_STUDENT = new UserType("_s", "学生");
    public static boolean userAuthentication(String url,String pathUserType,String roleType){
        if(pathUserType.equals("user")){
            if(url.contains("_s")){
                if(roleType.equals(RoleTypeEnum.STUDENT.getKey())){
                    return true;
                }else {
                    return false;
                }
            }
            if(roleType.equals(RoleTypeEnum.ADMIN.getKey())){
                return true;
            }else {
                return false;
            }
        }
        if(pathUserType.equals("Homework")){
            if(roleType.equals(RoleTypeEnum.TEACHER.getKey())){
                return true;
            }else {
                return false;
            }
        }
        if(pathUserType.equals("work-submit-info-entity")){
            if(roleType.equals(RoleTypeEnum.STUDENT.getKey())){
                return true;
            }else {
                return false;
            }
        }
        if(pathUserType.equals("class")||pathUserType.equals("team")||pathUserType.equals("course")){
            if(roleType.equals(RoleTypeEnum.ADMIN.getKey())){
                return true;
            }else {
                return false;
            }
        }
        return false;
    }
    private final String name;
    private final String format;
    public static List<String> getPaths(){
        return paths;
    }
}
